<template>
  <el-table :data="dataList" border @selection-change="handleSelectionChange">
    <el-table-column type="selection" width="55">
    </el-table-column>
    <el-table-column prop="transactionType" label="事务处理类型" width="100" fixed="left" />
    <el-table-column prop="sourceCode" label="来源" />


    <el-table-column prop="organizationCode" label="库房组织" width="100" />
    <el-table-column prop="subInventoryCode" label="子库房" width="100" />
    <el-table-column prop="materialCode" label="物料编码" />

    <el-table-column prop="materialDesc" label="物料描述" />
    <el-table-column prop="amount" label="数量" width="80" />
    <el-table-column prop="materialUnit" label="物料单位" width="50" />

    <el-table-column prop="unitPrice" label="采购单价" width="100" />
    <el-table-column prop="poOrderNumber" label="采购订单号" width="100" />

    <el-table-column prop="transactionProcessTime" label="事务处理时间" width="120">
      <template v-slot="scope">
        <span>{{ timeFormat(scope.row.transactionProcessTime, 'y2s') }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="createBy" label="创建人" width="100" />
    <el-table-column fixed="right" label="操作" width="150">
      <template v-slot="scope">
        <el-button type="success" size="small" @click="showJournalList(scope.row.businessId)">查看分录信息</el-button>
      </template>
    </el-table-column>

  </el-table>
</template>

<script lang="ts" setup>
import { CostTransactionProcess } from "@/requests/request";
import { exportExcel, filterExcelContentArr } from "@/utils/excel";
import { timeFormat } from "@/utils/time"
import { purTableHeader, purTableProps } from "../data";

defineProps({
  dataList: Array<CostTransactionProcess>
});

const showJournalList = (businessId: string) => {
  emit('showJournalList', businessId);
}

const emit = defineEmits(['showJournalList'])
let selectedArr: Array<any> = []
const handleSelectionChange = (val: Array<any>) => {
  console.log('选择的值', val);
  selectedArr = val;
}
const exportItems = () => {
  const sheetArr = filterExcelContentArr(selectedArr, purTableProps, purTableHeader)
  console.log('过滤的值', sheetArr)
  exportExcel("事务处理明细.xlsx", sheetArr)

}
// 暴露出去被引用
defineExpose({
  exportItems
})
</script>
<style lang="scss" scoped>
// :deep(.el-table__header th) {
//   height: 80px;
// }
</style>